package com.libbase.adapter;

import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import com.libbase.fragment.NewMvpKFragment;

import java.util.ArrayList;
import java.util.List;

public class NyqfAdapter extends FragmentStatePagerAdapter {

    List<String> codes;
    List<String> titles;

    public NyqfAdapter(FragmentManager fm) {
        super(fm);
        codes = new ArrayList<>();
        titles = new ArrayList<>();
    }

    public void setTitles(List<String> t) {
        titles.clear();
        titles.addAll(t);
    }

    public void setNewData(List<String> dataBeans) {
        codes.clear();
        codes.addAll(dataBeans);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return codes.size();
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @NonNull
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public Fragment getItem(int i) {
        return NewMvpKFragment.Companion.newInstance(titles.get(i), codes.get(i));
    }

    @Override
    public int getItemPosition(@NonNull Object object) {
        return POSITION_NONE;
    }
}